package com.ezops.filter;

import java.util.HashMap;
import java.util.Map;

import com.ezops.dto.RemoteRequest;
import com.ezops.dto.ReportRequest;
import com.ezops.filter.ReportCriteria.Filter;

public class ReportCriteriaImpl implements ReportCriteria {

	private Map<Filter, Object> filterMap;

	private ReportCriteriaImpl() {
		this.filterMap = new HashMap<>();
	}

	public static ReportCriteria createInstance() {
		return new ReportCriteriaImpl();
	}

	@Override
	public <T> ReportCriteria addFilter(Filter filter, T filterValue) {
		filterMap.put(filter, filterValue);
		return this;
	}

	@Override
	public <E> E getFilterValue(Filter filter, Class<E> type) {
		return (E) filterMap.get(filter);
	}

	@Override
	public Object getFilterValue(Filter filter) {
		return this.filterMap.get(filter);
	}

	@Override
	public RemoteRequest build() {
		//Add precondition for a filter REPORT_DISPLAY_NAME
		return new ReportRequest(this.getFilterValue(Filter.REPORT_DISPLAY_NAME)
				.toString());

	}

}
